<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Manager_Index extends Controller_Manager_Template_Default {

        public function before()
        {
            parent::before();
        }
    
	public function action_index()
	{		
            if (Auth::instance()->logged_in())             
            {                
                $this->request->redirect('manager/user');
            } 
            else 
            {			
                $this->request->redirect('manager/login');
            }                
	}
        
        public function action_login()
        {        
            Auth::instance()->login($this->request->post('username'),  $this->request->post('password'));

            if (Auth::instance()->logged_in()) 
            {
                echo "1";
            }
            else
            {
                echo "0";
            } 

            exit;
        }

        public function action_logout()
        {            
            if(Auth::instance()->logout(true, true))
            {
                $this->request->redirect("manager/login");
            }
        }         
        
}
